<?php
include("pChart2.1.4/class/pData.class.php");
include("pChart2.1.4/class/pDraw.class.php");
include("pChart2.1.4/class/pImage.class.php");

// Conexión a la BBDD
		$connect = mysql_connect("localhost:3306","administrador", "administrador");
		if (!$connect) {
			die(mysql_error());
		}
		mysql_select_db("administrador");
		
		// Saco datos de los 30 días
		$results = mysql_query('SELECT DFEC_FECHA, SPEED from T_SPEED WHERE DFEC_FECHA > (CURDATE() - INTERVAL 10 DAY) ORDER BY DFEC_FECHA ASC ');
		
		$row_fecha = array();
		$row_speed = array();
		
		while ($row = mysql_fetch_array($results, MYSQL_ASSOC)) {
			 $row_fecha[] = $row['DFEC_FECHA'];
			 $row_speed[] = $row['SPEED'];
		}
		
$myData = new pData();

$myData->addPoints($row_speed, "Speed");
$myData->setSerieDescription("Speed","Speed");
$myData->setSerieOnAxis("Speed",0);

//$myData->addPoints($row_fecha,"Absissa");
//$myData->setAbscissa("Absissa");

$myData->setAxisPosition(0,AXIS_POSITION_LEFT);
$myData->setAxisName(0,"1st axis");
$myData->setAxisUnit(0,"");

$myPicture = new pImage(700,230,$myData,TRUE);
$myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0));

$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>50,"G"=>50,"B"=>50,"Alpha"=>20));

$myPicture->setFontProperties(array("FontName"=>"pChart2.1.4/fonts/Bedizen.ttf","FontSize"=>18));
$TextSettings = array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE, "R"=>0, "G"=>0, "B"=>0);
$myPicture->drawText(350,25,"Download Speed",$TextSettings);

$myPicture->setShadow(FALSE);
$myPicture->setGraphArea(50,50,675,190);
$myPicture->setFontProperties(array("R"=>0,"G"=>0,"B"=>0,"FontName"=>"pChart2.1.4/fonts/pf_arma_five.ttf","FontSize"=>6));

$Settings = array("Pos"=>SCALE_POS_LEFTRIGHT
, "Mode"=>SCALE_MODE_FLOATING
, "LabelingMethod"=>LABELING_ALL
, "GridR"=>255, "GridG"=>255, "GridB"=>255, "GridAlpha"=>50, "TickR"=>0, "TickG"=>0, "TickB"=>0, "TickAlpha"=>50, "LabelRotation"=>0, "CycleBackground"=>1, "DrawArrows"=>1, "DrawXLines"=>1, "DrawSubTicks"=>1, "SubTickR"=>255, "SubTickG"=>0, "SubTickB"=>0, "SubTickAlpha"=>50, "DrawYLines"=>ALL);
$myPicture->drawScale($Settings);

$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>50,"G"=>50,"B"=>50,"Alpha"=>10));

$Config = array("DisplayValues"=>0, "BreakVoid"=>0, "BreakR"=>234, "BreakG"=>55, "BreakB"=>26);
$myPicture->drawSplineChart($Config);

$Config = array("FontR"=>0, "FontG"=>0, "FontB"=>0, "FontName"=>"pChart2.1.4/fonts/Bedizen.ttf", "FontSize"=>10, "Margin"=>6, "Alpha"=>30, "BoxSize"=>5, "Style"=>LEGEND_NOBORDER
, "Mode"=>LEGEND_HORIZONTAL
);
$myPicture->drawLegend(575,16,$Config);

$myPicture->stroke();
?>